/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.agh.air.bpel2bpmn.comparator.impl;

import org.agh.air.bpel2bpmn.comparator.AbstractComparator;
import org.agh.air.bpel2bpmn.exception.PatternNotFoundException;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 *
 * @author paletz
 */
public class SequenceComparator extends AbstractComparator {

    /* <process>
    <sequence>
    <invoke name="Task1"/>
    <invoke name="Task2"/>
    </sequence>
    </process>
     */
    @Override
    public String compare(Node node) throws PatternNotFoundException {

        if (node.getNodeName().equals(SEQUENCE)) {
            
            String str ="sequence" + LTMP; 
            for(int i=0;i<node.getChildNodes().getLength();i++){
                if(getIChild(node, i).getNodeName().equals(INVOKE))
                    str = str + getNameAttribute(getIChild(node, i));
                else
                    str = str + getIChild(node, i).getNodeName();
                
                if(i != node.getChildNodes().getLength()-1){
                    str = str + ".";
                }
            }
            
            
            return str + RTMP;
        }
        
        throw new PatternNotFoundException();
    }
}
